$(function () {
    var adrr =window.location.href
    if(adrr.indexOf("?")>-1){
        showStu(adrr.split("?")[1]);
    }else{
        showStu("");
    }


});


Vue.component('v-select', VueSelect.VueSelect);
var vm = new Vue({
    el:'#rrapp',
    data:{
        showList: true,


        title:"学生列表",


    },
    methods: {
        query: function () {


        },
        reload: function (cid) {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');

            $("#jqGrid").jqGrid('setGridParam',{

                page:page
            }).trigger("reloadGrid");
        }
    }
});



function  showStu(cid){

    $("#jqGrid").jqGrid('clearGridData');
    $("#jqGrid").jqGrid({
        url: baseURL + 'guide/stuQuery?cid='+cid,
        datatype: "json",
        colModel: [
            { label: 'ID', name: 'id', hidden: true, index: "id",  key: true },

            { label: '学号', name: 'sno',  width: 80 },
            { label: '姓名', name: 'sname',  width: 40 },
            { label: '手机号', name: 'phone', width: 80 },
            { label: '学分', name: 'score',  width: 40  },
            { label: '操作',formatter:function(value,options,rowData){
                    return '<b><span  onclick="update('+rowData.id+')"  style="cursor:pointer;" class="label label-success">加分</span></b> | ' +
                        '<b><span  onclick="del('+rowData.id+')"  style="cursor:pointer;" class="label label-warning">减分</span></b>';

                }
            }


        ],
        viewrecords: true,

        autowidth:true,
        // multiselect: true,
        height: 385,
        rowNum: 10,
        rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth:true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGridStu").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    }).trigger("reloadGrid");
}